<?php

/**
 * This is the model class for table "tbl_inpatients".
 *
 * The followings are the available columns in table 'tbl_inpatients':
 * @property string $pk_inpatient_id
 * @property string $fk_inpatient_bed_id
 * @property string $phone
 * @property integer $gender
 * @property string $dob
 * @property integer $blood_type
 * @property string $ture_name
 * @property string $email
 * @property string $portrait_url
 * @property integer $weight
 * @property integer $stature
 * @property integer $to_research
 * @property string $create_time
 * @property string $update_time
 */
class TblInpatients extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_inpatients';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('pk_inpatient_id, fk_inpatient_bed_id, create_time, update_time', 'required'),
			array('gender, blood_type, weight, stature, to_research', 'numerical', 'integerOnly'=>true),
			array('pk_inpatient_id, fk_inpatient_bed_id', 'length', 'max'=>20),
			array('phone, ture_name', 'length', 'max'=>100),
			array('email, portrait_url', 'length', 'max'=>200),
			array('dob', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('pk_inpatient_id, fk_inpatient_bed_id, phone, gender, dob, blood_type, ture_name, email, portrait_url, weight, stature, to_research, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'pk_inpatient_id' => 'Pk Inpatient',
			'fk_inpatient_bed_id' => 'Fk Inpatient Bed',
			'phone' => 'Phone',
			'gender' => 'Gender',
			'dob' => 'Dob',
			'blood_type' => 'Blood Type',
			'ture_name' => 'Ture Name',
			'email' => 'Email',
			'portrait_url' => 'Portrait Url',
			'weight' => 'Weight',
			'stature' => 'Stature',
			'to_research' => 'To Research',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('pk_inpatient_id',$this->pk_inpatient_id,true);
		$criteria->compare('fk_inpatient_bed_id',$this->fk_inpatient_bed_id,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('gender',$this->gender);
		$criteria->compare('dob',$this->dob,true);
		$criteria->compare('blood_type',$this->blood_type);
		$criteria->compare('ture_name',$this->ture_name,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('portrait_url',$this->portrait_url,true);
		$criteria->compare('weight',$this->weight);
		$criteria->compare('stature',$this->stature);
		$criteria->compare('to_research',$this->to_research);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return TblInpatients the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
